package cn.itcast.hotel.constants;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author mrchen
 * @date 2022/2/18 11:37
 */
@Configuration
public class RabbitConfig {
    @Bean
    public TopicExchange hotelTopic(){
        return new TopicExchange(MqConstants.HOTEL_EXCHANGE);
    }
    @Bean
    public Queue insertQueue(){
        return new Queue(MqConstants.HOTEL_INSERT_QUEUE);
    }
    @Bean
    public Queue deleteQueue(){
        return new Queue(MqConstants.HOTEL_DELETE_QUEUE);
    }
    @Bean
    public Binding insertBinding(){
        return BindingBuilder.bind(insertQueue()).to(hotelTopic()).with(MqConstants.HOTEL_INSERT_KEY);
    }
    @Bean
    public Binding deleteBinding(){
        return BindingBuilder.bind(deleteQueue()).to(hotelTopic()).with(MqConstants.HOTEL_DELETE_KEY);
    }
}
